package com.kx.core.ftl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.kx.core.jdbc.domain.City;
import com.kx.core.jdbc.service.CityService;

/**
 * 城市 Controller 实现 Restful HTTP 服务
 * @author     Kangx.li 1703054
 * @version    V1 2018年11月23日
 * @since      Java
 */
@Controller
public class CityController {

    @Autowired
    private CityService cityServiceImpl;
    
    @RequestMapping(value = "/ftl/city/{id}", method = RequestMethod.GET)
    public String findOneCity(Model model, @PathVariable("id") Long id) {
        model.addAttribute("city", cityServiceImpl.findCityById(id));
        return "city";
    }

    @RequestMapping(value = "/ftl/city", method = RequestMethod.GET)
    public String findAllCity(Model model) {
        List<City> cityList = cityServiceImpl.findAllCity();
        model.addAttribute("cityList",cityList);
        return "cityList";
    }
}

